package net.lab1024.sa.admin.module.business.traffic.aibi.controller;

import java.util.List;

import cn.dev33.satoken.annotation.SaCheckPermission;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import net.lab1024.sa.admin.constant.AdminSwaggerTagConst;
import net.lab1024.sa.admin.module.business.traffic.aibi.domain.form.AibiCarQueueQueryForm;
import net.lab1024.sa.admin.module.business.traffic.aibi.domain.vo.AibiCameraStatusVO;
import net.lab1024.sa.admin.module.business.traffic.aibi.domain.vo.AibiCarQueueVO;
import net.lab1024.sa.admin.module.business.traffic.aibi.service.AibiCameraStatusService;
import net.lab1024.sa.admin.module.business.traffic.aibi.service.AibiCarQueueService;
import net.lab1024.sa.base.common.domain.PageResult;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 艾比摄像机数据接口
 */
@RestController
@RequestMapping("/traffic/aibi")
@Tag(name = AdminSwaggerTagConst.Business.TRAFFIC_AIBI)
public class AibiCameraController {

    @Resource
    private AibiCarQueueService carQueueService;

    @Resource
    private AibiCameraStatusService cameraStatusService;

    @Operation(summary = "分页查询艾比摄像机排队数据")
    @PostMapping("/car-queue/query")
    @SaCheckPermission("traffic:aibi:query")
    public ResponseDTO<PageResult<AibiCarQueueVO>> queryCarQueue(@RequestBody @Valid AibiCarQueueQueryForm queryForm) {
        return ResponseDTO.ok(carQueueService.queryPage(queryForm));
    }

    @Operation(summary = "查询艾比摄像机最新状态")
    @GetMapping("/status/latest")
    @SaCheckPermission("traffic:aibi:query")
    public ResponseDTO<List<AibiCameraStatusVO>> latestStatus() {
        return ResponseDTO.ok(cameraStatusService.listStatus());
    }
}

